<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书管理</title>
	<%@include file="/pages/common/head.jsp"%>
	<script type="text/javascript">
		$(function (){
			$("a.delclass").click(function (){
				/**
				 * confirm 是确认提示框函数
				 * 参数是它的提示内容
				 * 它有两个按钮，一个是确认，一个是取消
				 * 返回true表示点击确认 返回false表示点击取消
				 */
				return confirm("确定要删除该图书吗？");
			});
			$("#searchPageBtn").click(function (){
				var pageNo = $("#pn_input").val();
				var pageTotal=${requestScope.page.pageTotal};
				//js语言中提供了一个 location 地址栏对象
				//它有一个属性 href ，它可以获取浏览器地址栏中的地址;
				//href属性 可读，可写
				if(pageNo>=1 && pageNo<=pageTotal){
					location.href="${requestScope.page.url}&pageNo="+pageNo;
				}
			});
		});
	</script>
	<style>
		a{text-decoration: none}
	</style>
</head>
<body>
	<div id="header">
			<img class="logo_img" alt="" src="static/img/logo.jpg" >
			<span class="wel_word">图书管理系统</span>
			<%@include file="/pages/common/manager_menu.jsp"%>
	</div>
	
	<div id="main">
		<table>
			<tr>
				<td>名称</td>
				<td>价格</td>
				<td>作者</td>
				<td>销量</td>
				<td>库存</td>
				<td colspan="2">操作</td>
			</tr>

			<c:forEach items="${requestScope.page.items}" var="book">
				<tr>
					<td>${book.name}</td>
					<td>${book.price}</td>
					<td>${book.author}</td>
					<td>${book.sales}</td>
					<td>${book.stock}</td>
					<td><a href="manager/bookManager?action=getBook&id=${book.id}&pageNo=${requestScope.page.pageNo}">修改</a></td>
					<td><a class="delclass" href="manager/bookManager?action=del&id=${book.id}&pageNo=${requestScope.page.pageNo}">删除</a></td>
				</tr>
			</c:forEach>

			<tr>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td></td>
				<td><a href="pages/manager/book_edit.jsp?pageNo=${requestScope.page.pageTotal}">添加图书</a></td>
			</tr>	
		</table>
	</div>
	<%@include file="/pages/common/page_nav.jsp"%>
	<%@include file="/pages/common/footer.jsp"%>
</body>
</html>